/*
 * ConfigureInfo.cpp
 *
 *  Created on: 2011-4-28
 *      Author: wugang
 */

#include "ConfigureInfo.h"
#include <cstdio>
#include <cstring>
#include "CfgFile.h"

ConfigureInfo::ConfigureInfo() {
	memset(&m_confInfo,0,sizeof(ConfInfo));
}

ConfigureInfo::~ConfigureInfo() {

}


//功能：从配置文件中读取用户信息
int ConfigureInfo::readConfigUserInfo(char* cName,char* cPwd)
{
	if(cName == NULL || cPwd == NULL)
	{
		return -1;
	}
	char strTmp[50];
	memset(strTmp,0,50);
	sprintf(strTmp,"user0");
	CfgFile::readCfgfileString((const char*)strTmp,"username",(char *)m_confInfo.cName,sizeof(m_confInfo.cName),"",USER_CFG_FILE);
	CfgFile::readCfgfileString((const char*)strTmp,"password",(char *)m_confInfo.cPwd,sizeof(m_confInfo.cPwd),"",USER_CFG_FILE);

	memcpy(cName,m_confInfo.cName,sizeof(m_confInfo.cName));
	memcpy(cPwd,m_confInfo.cPwd,sizeof(m_confInfo.cPwd));

	//DBG_PRINTINFO("userName:%s\n",cName);
	//DBG_PRINTINFO("pwd:%s\n",cPwd);
	return 0;
}
